home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tclX6.4c / dist / tests / fcntl.test < prev    next >
Encoding:
Text File  |  1992-11-07  |  2.8 KB  |  108 lines

  1. #
  2. # fcntl.test
  3. #
  4. # Tests for the fcntl command.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1992 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: fcntl.test,v 2.0 1992/10/16 04:49:41 markd Rel $
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. if {[info procs test] != "test"} then {source testlib.tcl}
  20.  
  21. set testFH [open FCNTL.TMP w]
  22. close $testFH
  23.  
  24. set testFH [open FCNTL.TMP r+]
  25.  
  26. test fcntl-1.1 {fcntl tests} {
  27.     fcntl $testFH RDWR
  28. } {1}
  29.  
  30. test fcntl-1.2 {fcntl tests} {
  31.     fcntl $testFH READ
  32. } {1}
  33.  
  34. test fcntl-1.3 {fcntl tests} {
  35.     fcntl $testFH WRITE
  36. } {1}
  37.  
  38. test fcntl-1.4 {fcntl tests} {
  39.     fcntl $testFH CLOEXEC 1
  40.     fcntl $testFH CLOEXEC
  41. } {1}
  42.  
  43. test fcntl-1.5 {fcntl tests} {
  44.     fcntl $testFH CLOEXEC 0
  45.     fcntl $testFH CLOEXEC
  46. } {0}
  47.  
  48. test fcntl-1.6 {fcntl tests} {
  49.     fcntl $testFH NONBLOCK 1
  50.     fcntl $testFH NONBLOCK
  51. } {1}
  52.  
  53. test fcntl-1.7 {fcntl tests} {
  54.     fcntl $testFH append 1
  55.     list [fcntl $testFH append] [fcntl $testFH nonblock]
  56. } {1 1}
  57.  
  58. test fcntl-1.8 {fcntl tests} {
  59.     fcntl $testFH APPEND 0
  60.     list [fcntl $testFH append] [fcntl $testFH nonblock]
  61. } {0 1}
  62.  
  63. test fcntl-1.9 {fcntl tests} {
  64.     fcntl $testFH NONBLOCK 0
  65.     fcntl $testFH nonBlock
  66. } {0}
  67.  
  68. test fcntl-1.10 {fcntl tests} {
  69.     fcntl $testFH NOBUF 1
  70.     fcntl $testFH NObuf
  71. } {1}
  72.  
  73. test fcntl-1.11 {fcntl tests} {
  74.     list [catch "fcntl $testFH NOBUF 0" msg] $msg
  75. } {1 {Attribute "NOBUF" may not be cleared once set}}
  76.  
  77. close $testFH
  78. set testFH [open FCNTL.TMP r+]  ;# Reopen, can not have both nobuf and linebuf
  79.  
  80. test fcntl-1.12 {fcntl tests} {
  81.     fcntl $testFH LINEBUF 1
  82.     fcntl $testFH LINEBUF
  83. } {1}
  84.  
  85. test fcntl-1.13 {fcntl tests} {
  86.     list [catch "fcntl $testFH LINEBUF 0" msg] $msg
  87. } {1 {Attribute "LINEBUF" may not be cleared once set}}
  88.  
  89. test fcntl-1.14 {fcntl tests} {
  90.     list [catch "fcntl $testFH a b c" msg] $msg
  91. } {1 {wrong # args: fcntl handle attribute [value]}}
  92.  
  93. test fcntl-1.15 {fcntl tests} {
  94.     list [catch "fcntl $testFH BAZ 1" msg] $msg
  95. } {1 {unknown attribute name "BAZ", expected one of APPEND, CLOEXEC, LINEBUF, NONBLOCK, NOBUF, READ, RDONLY, RDWR, WRITE, WRONLY}}
  96.  
  97. test fcntl-1.16 {fcntl tests} {
  98.     list [catch "fcntl $testFH APPEND FOO" msg] $msg
  99. } {1 {expected boolean value but got "FOO"}}
  100.  
  101. close $testFH
  102.  
  103. test fcntl-1.15 {fcntl tests} {
  104.     list [catch "fcntl $testFH RDONLY" msg] $msg
  105. } [list 1 "file \"$testFH\" isn't open"]
  106.  
  107. unlink FCNTL.TMP
  108.